//
//  SWPinkFilter.swift
//  ChildStory
//
//  Created by linhan on 16/8/30.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation
class SWPinkFilter: SWBaseFilter
{
    override var name:String{
        return "粉嫩"
    }
    
    override func execute(image:UIImage, info:[String:Any]?)
    {
        DispatchQueue.global(priority: .default).async(execute: {
            let smoothImage:UIImage? = info?[SWBaseFilter.SkinSmoothImageKey] as? UIImage ?? SWFilterUtil.skinSmooth(image)
            if let smoothImage = smoothImage,
                let result = PWCPUFilterImplementation.filterPink(smoothImage)
            {
                self.delegate?.filterProcessCompletion(self, image: result, info: [SWBaseFilter.SkinSmoothImageKey:smoothImage])
            }else{
                self.delegate?.filterProcessFail(self, error: SWError.FilterDefaultError)
            }
            
        })
    }
    
    override func execute(image:UIImage, info:[String:Any]?, successCallback:@escaping ((UIImage)->Void), failCallback:((NSError)->Void)?)
    {
        DispatchQueue.global(priority: .default).async(execute: {
            let smoothImage:UIImage? = info?[SWBaseFilter.SkinSmoothImageKey] as? UIImage ?? SWFilterUtil.skinSmooth(image)
            if let smoothImage = smoothImage,
                let result = PWCPUFilterImplementation.filterPink(smoothImage)
            {
                successCallback(result)
            }else{
                failCallback?(SWError.FilterDefaultError)
            }
            
        })
    }
    
    
    
}
